package com.xiaoma.tpo.webservice;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xiaoma.tpo.domain.ClsSentence;
import com.xiaoma.tpo.domain.ClsWord;
import com.xiaoma.tpo.service.SentenceService;
import com.xiaoma.tpo.service.WordService;
import com.xiaoma.tpo.utils.Pager;

@Controller
public class WordSentence {
	
	@Autowired
	private WordService wordService;
	@Autowired
	private SentenceService sentenceService;
	
	@RequestMapping(value="word/listAll",method=RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> listAllWord(Integer page,Integer rows,Integer clsGateId,String code,String word,String wordCn){
		Map<String, Object> result = new HashMap<String, Object>();
		Pager pager = wordService.findAllWords(page,rows,clsGateId,code,word,wordCn);
		result.put("total", pager.getTotalCount());
		result.put("rows", pager.getList());
		return result;
	}
	@RequestMapping(value="word/edit",method=RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> editWord( ClsWord clsWord){
		Map<String, Object> result = new HashMap<String, Object>();
		wordService.update(clsWord);
		return result;
	}
	@RequestMapping(value="sentence/listAll",method=RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> listAllSentence(Integer page,Integer rows,Integer id,String code,String sentence,String sentenceCn){
		Map<String, Object> result = new HashMap<String, Object>();
		Pager pager = sentenceService.findAllWords(page,rows,id,code,sentence,sentenceCn);
		result.put("total", pager.getTotalCount());
		result.put("rows", pager.getList());
		return result;
	}
	@RequestMapping(value="sentence/edit",method=RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> editSentence( ClsSentence clsSentence){
		Map<String, Object> result = new HashMap<String, Object>();
		sentenceService.update(clsSentence);
		return result;
	}
}
